package com.hengda.museumonline.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

/**
 * @author：JFWU on 2016/10/10 20:18
 * @E-mail：jeffy12138@126.com
 */
public class MyRecyclerView extends RecyclerView {
    private int downY;
    private int downX;

    public MyRecyclerView(Context context) {
        super(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        switch (e.getAction()) {
            case MotionEvent.ACTION_DOWN:
                downY = (int) e.getY();
                downX = (int) e.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                int moveY = (int) e.getY();
                int moveX = (int) e.getX();
                int diffY = moveY - downY;
                int diffX = moveY - downX;
                if (diffX > 8) {
                    return super.onInterceptTouchEvent(e);
                }
                break;
            default:
                break;

        }
        return true;
    }
}
